package api

import (
	"api-gateway/basic/config"
	__ "api-gateway/basic/proto"
	"api-gateway/handler/request"
	"api-gateway/handler/resp"
	"github.com/gin-gonic/gin"
)

func AddActivity(c *gin.Context) {
	var req request.AddActivityReq
	if err := c.ShouldBind(&req); err != nil {
		resp.Error(c, 400, "验证失败", err.Error())
		return
	}
	Aactivity, err := config.SeckillClient.AddActivityGoods(c, &__.AddActivityGoodsReq{
		GoodsId:       req.GoodsId,
		ActivityTitle: req.ActivityTitle,
		ActivityDesc:  req.ActivityDesc,
		ActivityPrice: float32(req.ActivityPrice),
		ActivityStock: req.ActivityStock,
		StartTime:     req.ActivityStartTime,
		EndTime:       req.ActivityEndTime,
	})
	if err != nil {
		resp.Error(c, 400, "添加秒杀商品失败", err.Error())
		return
	}
	resp.Success(c, "添加秒杀商品成功", Aactivity.ActivityId)
}
